package com.listeningframework.boot.codegen.generators.coders;

import com.listeningframework.boot.codegen.constants.Templates;
import com.listeningframework.boot.codegen.context.MetaContext;
import com.listeningframework.boot.codegen.exception.BusinessException;

import java.util.Map;

/**
 * 
 * @description Model Coder
 *
 * @author lixining
 * @version $Id: ModelCoder.java, v 0.1 2016年12月5日 下午1:53:49 lixining Exp $
 */
public class ModelCoder extends AbstractCoder {

    public ModelCoder(MetaContext context) {
        super(context);
    }

    @Override
    protected String getContent() throws BusinessException {
        return render(Templates.MODEL);
    }

    @Override
    protected Map<String, Object> getParams() {
        Map<String, Object> paramMap = newHashMap();
        paramMap.put(CLASS_PACKAGE, context.getDomainPackage());
        paramMap.put(CLASS_IMPORTS, context.getImports());
        paramMap.put(CLASS_METADATA_LIST, context.getEntityMetaList());
        return paramMap;
    }

    @Override
    protected String getSavePath() throws BusinessException {
        return context.getDomainPath();
    }

}
